<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .box {
            perspective: 1000px;
        }

        #content {
            position: relative;
            transform-style: preserve-3d;
            width: 900px;
            height: 400px;
            padding: 5% 25%;
        }

        #content li {
            position: absolute;
            transition: all 0.5s linear;
            transform-style: preserve-3d;
            float: left;
            width: 790px;
            height: 340px;
            margin: 0 auto;
        }

        #content li p {
            position: absolute;
            height: 100%;
            overflow: hidden;
        }



        .btn {
            transform: translateX(50%);
            margin-left: 50%;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul id="content"></ul>
    </div>
    <button class="btn">下一张</button>

    <script src="./lib/jquery.js"></script>
    <script>
        let deg = -90
        let isTrue = false

        for (let i = 0; i < 60; i++) {
            const li = $("<li></li>")
            for (let j = 0; j < 4; j++) {
                const num = i * 13.2
                const ps = $("<p></p>")

                ps.css({
                    "width": "14px",
                    "left": num
                })
                ps.appendTo(li)
                li.children().each(function (k) {
                    li.children().eq(0).css({
                        'transform': "translateZ(170px)",
                        "background": "url(./img/jd" + 1 + ".jpg) no-repeat ",
                        "background-position": -num + "px 0px "
                    })
                    li.children().eq(1).css({
                        'transform': "rotateX(90deg) translateZ(170px)",
                        "background": "url(./img/jd" + 2 + ".jpg) no-repeat ",
                        "background-position": -num + "px 0px "
                    })
                    li.children().eq(2).css({
                        'transform': "rotateX(180deg) translateZ(170px)",
                        "background": "url(./img/jd" + 3 + ".jpg) no-repeat ",
                        "background-position": -num + "px 0px "
                    })
                    li.children().eq(3).css({
                        'transform': "rotateX(270deg) translateZ(170px)",
                        "background": "url(./img/jd" + 4 + ".jpg) no-repeat ",
                        "background-position": -num + "px 0px "
                    })
                })
            }
            li.appendTo($("#content"))
        }


        $(".btn").stop(true).click(function () {

            if (isTrue) {
                return
            } else {
                $("#content").children().stop(true).each(function (i) {
                    $(this).stop(true).animate({}, 500, "linear", function () {
                        $(this).css({
                            "transform": "rotateX(" + deg + "deg)",
                            "transition": "all 0.5s linear " + i + "ms"
                        })
                    })
                })
                isTrue = true
                deg -= 90
                setTimeout(function () {
                    isTrue = false
                },800)
            }
        })

    </script>
</body>

</html>